import motor.motor_asyncio
from conf.config import mongodb_config

mongo_client = None
mongo_db = None


async def init_mongodb():
    """检测数据库连接"""
    global mongo_client, mongo_db
    mongo_client = motor.motor_asyncio.AsyncIOMotorClient(mongodb_config.MONGODB_URL)
    mongo_db = mongo_client[mongodb_config.MONGODB_DB]
    await mongo_db.list_collection_names()
